const util = require('../../utils/util.js');
const app = getApp();

Page({
    data: {
        userInfo: {},
        hasUserInfo: '',
        login: app.globalData.login
    },

    interest: function () {
        util.isLogin(function () {
            wx.navigateTo({
                url: '../interest/interest',
                success: function (res) {
                },
                fail: function (res) {
                },
                complete: function (res) {
                },
            })
        })
    },
    //退出登录
    logout: function () {
        let that = this;
        wx.showModal({
            title: '提示',
            content: '确定退出登录么',
            showCancel: true,
            cancelText: '取消',
            cancelColor: '#19ccc6',
            confirmText: '退出登录',
            confirmColor: '#19ccc6',
            success: function (res) {
                if (res.confirm) {
                    that.setData({
                        // login: false,
                    });
                    app.globalData.login = true;
                    app.globalData.phone = "";


                }
            },
            fail: function (res) {
            },
            complete: function (res) {
            },
        })

    },
    //事件处理函数
    bindViewTap: function () {
        wx.navigateTo({
            url: '../logs/logs'
        })
    },
    //商务合作
    callTel:function(){
        var that = this;
        wx.showActionSheet({
            itemList: ["15858287570","13858003993"],
            success: function (res) {
                if(res.tapIndex==0){
                    wx.makePhoneCall({
                        phoneNumber: "15858287570"
                    })
                }else{
                    wx.makePhoneCall({
                        phoneNumber: "13858003993"
                    })
                }
            
            },
            fail: function (res) {
                console.log(res.errMsg)
            }
        })
    },

    onLoad: function (options) {
        this.setData({
            userInfo: app.globalData.userInfo,
            hasUserInfo: app.globalData.hasUserInfo,
            login: app.globalData.login
        })

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.setData({
            login: app.globalData.login
        })
    },
    onShareAppMessage: function () {

    }
})